<!-- 交租记录 -->
<template>
  <div>
    <navbar title="交租记录"></navbar>
    <layout-main>
      <history-item
        v-for="historyItem in historyItems"
        v-bind:item="historyItem">
      </history-item>
    </layout-main>
  </div>
</template>
<script>
  import layoutMain from '../layout'
  import Navbar from '../components/Navbar'
  import historyItem from '../components/HistoryItem'

  import ajax from '../assets/ajax'

  export default {
    components: {
      layoutMain,
      Navbar,
      historyItem
    },
    data() {
      return {
        historyItems: []
      }
    },
    created() {
      this.getRentHistory()
    },
    methods: {
      getRentHistory() {
        // 获取用户的交租记录
        const data = ajax.handleData({
          methodId: '1021',
          data: {
            userId: this.$store.state.user.userId,
            pageSize: 999 // 暂无无限滚动加载
          }
        })
        this.$http.post(
          ajax.url,
          data
        ).then((response) => {
          const code = response.body.code
          if (code === '0') {
            this.historyItems = response.body.res.data.uoRentOrdersDto
          }
        }, (errResponse) => {
          console.log('error')
        })
      }
    }
  }
</script>
<style lang="less" scoped>
  .main {
    padding: 10px;
  }
</style>
